// Copyright (c) Microsoft Corporation
// All rights reserved

namespace Microsoft.Windows.Controls.Specialized.TextModel
{
    using System;

    /// <summary>
    /// Describes the text editing interface
    /// </summary>
    public interface ITextEdit
    {
        /// <summary>
        /// Inserts the given text in the specified location
        /// </summary>
        /// <param name="position">
        /// The position at which the given text is to be inserted
        /// </param>
        /// <param name="text">
        /// The text to be inserted
        /// </param>
        void Insert(int position, string text);

        /// <summary>
        /// Inserts an array of characters in the specified location
        /// </summary>
        /// <param name="position">
        /// The position at which the given text is to be inserted
        /// </param>
        /// <param name="buffer">
        /// The character array from which characters will be inserted
        /// </param>
        /// <param name="startIndex">
        /// The starting index of the text from the buffer
        /// </param>
        /// <param name="length">
        /// The length of text to insert
        /// </param>
        void Insert(int position, char[] buffer, int startIndex, int length);

        /// <summary>
        /// Deletes a range of characters from the underlying buffer
        /// </summary>
        /// <param name="startPosition">
        /// The position to start deleting from
        /// </param>
        /// <param name="charsToDelete">
        /// The number of characters to delete
        /// </param>
        void Delete(int startPosition, int charsToDelete);

        /// <summary>
        /// Replaces a range of characters with a some new text
        /// </summary>
        /// <param name="startPosition">
        /// The position to start replacing from
        /// </param>
        /// <param name="charsToDelete">
        /// The number of characters to replace
        /// </param>
        /// <param name="replaceWith">
        /// The new text to replace the old
        /// </param>
        void Replace(int startPosition, int charsToDelete, string replaceWith);

        /// <summary>
        /// Commits all the transactions to the underlying buffer
        /// </summary>
        [Obsolete("Please use Apply() method.", false)]
        void Commit();
        void Apply();
    }
}
